import React from 'react';
import { connect } from 'dva'
import queryString from 'query-string'
import {
  Button,
  Card,
  Tabs
} from 'antd'
import List from "./transferToBalanceRecordList";
import PageHeaderLayout from 'components/Layout/PageHeaderLayout';
import OrderFilterUnExpand from 'components/Filter/NormalFilter';
const transferToBalanceRecords = ({ location, dispatch, transferToBalanceRecord, app, loading }) => {
  location.query = queryString.parse(location.search);
  const { items, pagination,currentItem,detailVisible,isExpand, optionType, auditVisible, auditType, fileVisible, selectRows, selectedRowKeys, currentType} = transferToBalanceRecord;
  const TabPane = Tabs.TabPane;
  const breadcrumbList = [
    {
      title: '提现',

    }, {
      title: '提现审核',

    }
  ];
  const doAudit = (type, record) => {
    dispatch({
      type: 'transferToBalanceRecord/audit',
      payload: record
    })
  }
  const approve = (id, values) => {
    dispatch({
      type: 'transferToBalanceRecord/audit',
      payload: {
        id: id,
        values: values
      }
    })
  }
  const deny = (id) => {
    dispatch({
      type: 'transferToBalanceRecord/deny',
      payload: id
    })}
  const onShowAudit = (record) => {
    onShowDetail(record)
    setOptionType("audit")
  }

  const setOptionType = (type) => {
    dispatch({
      type: 'transferToBalanceRecord/setOptionType',
      payload: type
    })
  }
  const onShowDetail=(record)=>{
    setOptionType("detail")
    dispatch({
      type: 'transferToBalanceRecord/setDetailVisible',
      payload: true
    })
    dispatch({
      type: 'transferToBalanceRecord/detail',
      payload: record.id
    })
  }
  const listProps = {
    dataSource: items,
    loading: loading.effects['transferToBalanceRecord/query'],
    pagination,
    pageChangeAction: 'transferToBalanceRecord/query',
    global: loading.global,
    onShowDetail:onShowDetail,
    detailVisible,
    dispatch,
    optionType,
    currentItem,
    location,
    onShowAudit,
    auditVisible,
    deny,
    approve,
    doAudit,
    auditType,
    fileVisible

  };
  const filterProps = {
    filterItems: [
      {
        type: 'select',
        id: 'status',
        title: '状态',
        options: [
          {
            value: "",
            name: '全部'
          },
          {
            value:"PENDING",
            name:'待审核'
          },
          {
            value: 'CHECK_APPROVED',
            name: '审核通过'
          },
          {
            value: 'CHECK_DENY',
            name: '审核不通过'
          },
          {
            value: 'SUCCESS',
            name: '提现成功'
          }, {
            value: 'FAILED',
            name: '提现失败'
          }
        ]
      }
    ],
    onFilterChange (value) {
      dispatch({
        type: 'transferToBalanceRecord/query',
        payload: {
          ...value
        }
      })
    },
  }
return (
  <PageHeaderLayout title="提现审核" breadcrumbList={breadcrumbList}>
    <Card bordered={false}>
      <div >
      <OrderFilterUnExpand {...filterProps}/>
            <List {...listProps} />

      </div>
    </Card>
    </PageHeaderLayout>
)
};

export default connect(({transferToBalanceRecord, app, loading }) => ({ transferToBalanceRecord, app, loading }))(transferToBalanceRecords)

